home *** CD-ROM | disk | FTP | other *** search
/ Nikkei Mac 3 / NIKKEI-MAC-CD-VOL-03-1995-02-15.ISO.7z / NIKKEI-MAC-CD-VOL-03-1995-02-15.ISO / 圧縮ソフト / StuffIt Liteェ 3.5 Installer / StuffIt Lite™ 3.5 Installer / Scripting Tools / Scripting Addenda < prev    next >
Text File  |  1994-11-17  |  7KB  |  104 lines

  1. Scripting Addenda
  2.  
  3. This document describes Apple event based scripting features that are present in the StuffIt Lite application but were completed after the Userユs Guide was written. It also provides additional tips and explanations on scripting StuffIt Lite which are not covered in the Userユs Guide. 
  4.  
  5. Note, this document assumes that your copy of StuffIt Lite is registered. Unregistered copies of StuffIt Lite only support a small subset of the events ム メOpenモ, メCloseモ, メPrintモ, メQuitモ, メStuffモ and メUnStuffモ.
  6.  
  7. =============================================================================
  8.  
  9. StuffIt Lite 3.5 is extremely AppleEvent savvy. It can be automated using any Open Scripting Architecture (OSA) compliant scripting language such as AppleScript, Userland Frontier and QuicKeys.  However, to keep things simpler in the following discussion, the term AppleScript will be used メgenericallyモ and AppleScript syntax will be used in sample scripts shown below.
  10.  
  11. Support for AppleScript comes in two forms ム scriptability and recordability. Scriptability in this case means that ALL user actions ム from creating a new archive, to Stuffing & UnStuffing to translation ム can be automated via a script. Recordability offers you, the scriptor, a way to have your scripts (or at least parts of them) written for you by simply clicking メRecordモ in the AppleScript Script Editor and then just doing something ム a script will magically appear that mimics your actions.  
  12.  
  13. Since recordability is really just an extension to being scriptable, we'll spend the rest of the time discussing how you can interact with StuffIt from your scripts.
  14.  
  15. The first thing you need to know is that StuffIt supports a concept called the Apple event Object Model (AEOM) which gives applications a common vocabulary for similar tasks.  For example, in any AEOM based application (e.g. Microsoft Excel, Quark XPress, and others) I can ask for the name of the frontmost open window by writing メget the name of window 1モ.  
  16.  
  17. A common vocabulary is made possible by establishing a standard set (or suite) of events which the  application should support (such as get, set, make and count), as well as some standard objects that can be manipulated (such as windows, documents and applications).   The AEOM also creates a concept of メpropertyモ. Any given object has properties, which can be either read, set, or both. In the example above, a window has a name property that was read.  To change the name of the window, you would write メset the name of window 1 to MyWindowモ.  For a listing of the Standard Suite, open the StuffIt Lite dictionary from the AppleScript Script Editor.
  18.  
  19. StuffIt not only offers support for the Standard Suite of events and objects, but also offers its own events and objects that describe functionality specific to StuffIt.  New objects include archives, files and folders; new events include Stuff, UnStuff and translate. For a listing of the StuffIt Suite, open the StuffIt Lite dictionary from the AppleScript Script Editor.
  20.  
  21. Using this information, and the StuffIt Lite dictionary as our guide, let's look at some small sample scripts that automate StuffIt.  First is a script that counts the number of items at the top level of an archive and then gets the name and size of each one.  Although not very useful, it shows how you can count things (in this case the number of items in an archive) and also get information about them (such as their name and size).
  22.  
  23. tell application "StuffIt Liteェ"
  24.     count the items in archive 1
  25.     repeat with i from 1 to the result
  26.         get the name of item i of archive 1
  27.         get the size of item i of archive 1
  28.     end repeat
  29. end tell
  30.  
  31. In this next script, we will take those basic concepts of counting and getting information as well as some new ones to convert all StuffIt 1.5.1 archives that are open into StuffIt Lite 3.x archives containing a comment.   In this script we see how to use a StuffIt specific event (convert) as well as how to set a property (comment).
  32.  
  33. tell application "StuffIt Liteェ"
  34.     count the archives
  35.     repeat with i from 1 to the result
  36.         get the original format of archive i
  37.         if the result is true then
  38.             convert archive i
  39.             set the comment of archive i to "Converted from 1.5.1"
  40.         end if
  41.     end repeat
  42. end tell
  43.  
  44. Now that we've looked into working with objects and their properties, let's see how to do some simple StuffIt related operations - such as stuffing and unstuffing.   
  45.  
  46. To stuff a file or folder into an archive is quite simple you simply tell StuffIt to stuff, such as メtell application "StuffIt Liteェ" to stuff {alias "HD:note"}モ.  You could also take advantage of some of StuffIt's stuffing options such as encryption or having the original deleted by adding them to the script command as in メtell application "StuffIt Liteェ" to stuff {alias "HD:note"} with encryption and deleting originalsモ.  And of course, you don't always have to stuff into the frontmost archive, you could put those files and folders into any open archive by doing something like メtell application "StuffIt Liteェ" to stuff {alias "HD:note"} into the archive named "My Archive.sit"モ.
  47.  
  48. UnStuffing a file or folder from an archive is quite similar and can even be simpler.  To  unstuff the currently selected items to the same folder as the archive you can just say メtell application "StuffIt Liteェ" to unstuffモ.   If you want to place those items in a special folder on your disk, you would refer to it just as you did for stuffing by using the "into" expression such as メtell application "StuffIt Liteェ" to unstuff into {alias "HD:Downloads:"}モ.  If you need more control over what items to expand, you can specify the specific object like so, メtell application "StuffIt Liteェ" to unstuff file 1 of folder 1 of archive 1 into {alias "HD:Downloads:"}モ.
  49.  
  50. If you would like to see some more functional examples of using these commands and others (such as translate), we suggest that you look at the example scripts contained in the メScripting Toolsモ folder.   AppleScript users will find them in the メStuffIt & AppleScriptモ folder, while users of Userland Frontier will find a complete Install file (complete with sample shared menu) in the メStuffIt & Frontierモ folder.
  51.  
  52.  
  53. Additional Reading
  54. If you need more detailed information about scripting in general, we recommend the following books:
  55.  
  56. Author: Danny Goodman
  57. Title: The Complete AppleScript Handbook
  58. Publisher: Random House
  59. Date: 1993
  60.  
  61. Author: Derrick Schneider
  62. Title: The Tao of AppleScript
  63. Publisher: Hayden Books
  64. Date: 1993
  65.  
  66. Author: Christopher Allen
  67. Title: Everyday AppleScript
  68. Publisher: Addison-Wesley
  69. Date: 1994
  70.  
  71. Author: Apple Computer, Inc.
  72. Title: AppleScript Script Language Guide
  73. Publisher: Addison-Wesley
  74. Date: 1993
  75.  
  76. Author: Apple Computer, Inc.
  77. Title: AppleScript Script ing Additions Guide
  78. Publisher: Addison-Wesley
  79. Date: 1993
  80.  
  81. Also, check the Aladdin support areas on your favorite online service for more sample scripts and other helpful information.   
  82.  
  83. CONTACTING ALADDIN SYSTEMS
  84. Aladdin Systems, Inc.
  85. 165 Westridge Drive
  86. Watsonville, CA 95076
  87. ph. 408/761-6200 
  88. fax 408/761-6206
  89.  
  90. America Online/AppleLink: ALADDIN
  91. CompuServe: 75300,1666
  92. eWorld/GEnie: AladdinSys
  93. Internet: aladdin@well.com
  94.          
  95.    
  96. -----------
  97. LEGAL MUMBO JUMBO
  98.  
  99. Copyright (C) 1992-1994 Aladdin Systems, Inc. All Rights Reserved.
  100. StuffIt and StuffIt Lite are trademarks of Aladdin Systems, Inc. All
  101. other product names are trademarks or registered trademarks
  102. of their respective holders. Our lawyers are happy. :-)
  103.  
  104.